import Api from '../../../utils/httpImpl';
import utils from '../../../utils/utils';
const api = new Api();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    password: '', 
    confPsd: '', //确认密码
  }, 

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  confirm() {
    //密码项为空
    if (utils.strNotNull(this.data.password)) {
      wx.showToast({
        title: '请输入密码',
        icon: 'none'
      });
      return;
    }
    if(this.data.password !== this.data.confPsd) {
      wx.showToast({
        title: '密码不一致',
        icon: 'none'
      });
      return;
    }
    if(utils.psdEDCheck(this.data.password)){
      wx.showToast({
        title: '密码过于简单',
        icon: 'none'
      });
      return;
    }
    let _json = {
      user_id: wx.getStorageSync('userId'),
      user_name: wx.getStorageSync('userName'),
      user_psd: this.data.psd
    };
    api.modyfyPsd(_json);
  },
})